package com.example.sherlockzhong.plush_v2.CardBeans;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by DosonLeung on 2014/8/13.
 * Note:All the String[]'s length depend on the String Array headers[]'s length;
 */

public class ConsumptionBean {
    Double sums = null;
    private String headers[] = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined"};
    private String contents[] = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined"};
    private String detials[] = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined"};
    private List<Map<String, Object>> otherlist = null;
    private int Length = 0;

    public String[] getHeaders() {
        return headers;
    }

    public void setHeaders(String[] header) {
        if (headers != null) {
            this.headers = new String[Length];
            for (int i = 0; i < Length; i++) {
                this.headers[i] = header[i];
            }
        }
    }

    public String[] getContents() {
        return contents;
    }

    public void setContents(String[] content) {
        if (contents != null) {
            this.contents = new String[Length];
            for (int i = 0; i < Length; i++) {
                this.contents[i] = content[i];
            }
        }
    }

    public String[] getDetials() {
        return detials;
    }

    public void setDetials(String[] detial) {
        if (detials != null) {
            this.detials = new String[Length];
            for (int i = 0; i < Length; i++) {
                this.detials[i] = detial[i];
            }
        }
    }

    public int getLength() {
        return Length;
    }

    public void setLength(int length) {
        Length = length;
    }

    public List<Map<String, Object>> generateConsumeListData() {
        this.otherlist = new ArrayList<Map<String, Object>>();
        if (Length > 0) {
            for (int i = 0; i < Length; i++) {
                Map<String, Object> listItems = new HashMap<String, Object>();
                listItems.put("header", this.headers[i]);
                listItems.put("content", this.contents[i]);
                listItems.put("detial", this.detials[i]);
                this.otherlist.add(listItems);
            }
        }
        return this.otherlist;
    }

    public String getSum() {
        if (sums != null) {
            String sum = sums.toString();
            if (sum == "0.0")
                return "0";
            else
                return sum;
        } else {
            return "0.0";
        }
    }

    public void setSum(Double sum) {
        this.sums = sum;
    }
}
